feat(evm): standardize slow block JSON output for cross-client metrics#21237
Closed
CPerezz wants to merge 13 commits intoparadigmxyz:mainfrom
Closed
feat(evm): standardize slow block JSON output for cross-client metrics#21237CPerezz wants to merge 13 commits intoparadigmxyz:mainfrom
CPerezz wants to merge 13 commits intoparadigmxyz:mainfrom
Conversation
0c03b2d to
7754be2
Compare
7754be2 to
64e1bfc
Compare
310af2a to
d37c498
Compare
Implements execution metrics following the cross-client specification: https://github.com/ethereum/execution-specs/blob/main/docs/execution-metrics-spec.md - Add slow block logging method to ExecutorMetrics - Output structured JSON log entries for cross-client analysis - Include timing, throughput, and state access counts - Threshold configurable via SLOW_BLOCK_THRESHOLD_MS constant
Implement standardized JSON format for slow block logging to enable cross-client performance analysis and protocol research. This change is part of the Cross-Client Execution Metrics initiative proposed by Gary Rong: https://hackmd.io/dg7rizTyTXuCf2LSa2LsyQ The standardized metrics enabled data-driven analysis like the EIP-7907 research: https://ethresear.ch/t/data-driven-analysis-on-eip-7907/23850 JSON format includes: - block: number, hash, gas_used, tx_count - timing: execution_ms, total_ms - throughput: mgas_per_sec - state_reads: accounts, storage_slots, code, code_bytes - state_writes: accounts, storage_slots - cache: account/storage/code hits, misses, hit_rate
Convert timing parameters from u64 to f64 to preserve sub-millisecond
precision in slow block JSON output.
Changes:
- log_slow_block() timing params: u64 -> f64
- is_slow_block(): u64 -> f64 with threshold cast
- Tracing format: add {:.3} for 3 decimal places
- Update tests for f64 values
Add tracking for EIP-7702 delegation set/cleared operations as part of the cross-client execution metrics standardization effort. New parameters in log_slow_block(): - eip7702_delegations_set: Number of EIP-7702 delegations set - eip7702_delegations_cleared: Number of EIP-7702 delegations cleared These fields will be 0 for pre-Pectra blocks per spec.
Add core infrastructure for tracking block execution metrics: - ExecutionStats struct with state reads/writes/cache fields - EIP-7702 delegation counters - Timing breakdown (execution, state_read, state_hash, commit)
Wire ExecutionStats collection into the engine tree: - Add instrumented state wrapper for metrics capture - Integrate with payload validation pipeline - Add slow block logging with JSON output - Fix eip7702_delegations_cleared detection logic The fix changes from checking was_destroyed() to detecting bytecode transition from EIP-7702 format to empty.
Add CLI configuration for slow block metrics: - --debug.slow-block-threshold <duration> to set logging threshold - Default: disabled (no slow block logging) - Set to 0 to log all blocks
Add comprehensive tests for slow block metrics: - EIP-7702 delegation set/cleared scenarios - Contract deployment metrics - Storage operation metrics - Edge cases (revert, OOG)
Fix compilation errors from rebase onto upstream/main: - Remove orphaned SlotStatus/inc_* merge remnants in cached_state.rs - Add missing executor.finish() and db.merge_transitions() in payload_validator.rs - Add account_cache_size field and get_cache_stats() method to CachedStateMetrics - Add missing closing brace in metrics.rs record_block_execution - Enable slow block logging in threshold filtering test - Update verification report with post-rebase test results
…on report Add 5 new tests to execution_metrics_test.rs for complete coverage of slow_block_test_vectors.json: - test_transfer_to_new_account_creates_account (A2) - test_factory_deploys_multiple_contracts (C2) - test_empty_block_metrics (EDGE1) - test_reverted_transaction_excludes_state_changes (EDGE2) - test_out_of_gas_reverts_all_changes (EDGE3)
- Add `const` to `timing_stats` function in ExecutedBlock - Fix tab-to-space indentation in crates/evm/evm/Cargo.toml std features
ccc64e3 to
2e45bc7
Compare
Member
|
Thank you for the initial implementation, taking this over here #21433 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement standardized JSON format for slow block logging to enable cross-client performance analysis and protocol research.
This change is part of the Cross-Client Execution Metrics initiative proposed by Gary Rong and CPerezz.
Motivation
Standardized execution metrics are critical for:
Real-world example: The EIP-7907 analysis used execution metrics to measure code read latency, per-call overhead scaling, and block execution breakdown. Without standardized metrics across clients, such analysis cannot be validated cross-client.
References
JSON Format
{ "level": "warn", "msg": "Slow block", "block": { "number": ..., "hash": ..., "gas_used": ..., "tx_count": ... }, "timing": { "execution_ms": ..., "total_ms": ... }, "throughput": { "mgas_per_sec": ... }, "state_reads": { "accounts": ..., "storage_slots": ..., "code": ..., "code_bytes": ... }, "state_writes": { "accounts": ..., "storage_slots": ... }, "cache": { "account": { "hits": ..., "misses": ..., "hit_rate": ... }, "storage": { ... }, "code": { ... } } }Example trace:
{ "timestamp": "2026-01-25T12:33:51.268394Z", "level": "WARN", "fields": { "message": "Slow block", "block.number": 9, "block.hash": "0x02e95075ddbb6866370968d92014b789f5917c05784e6091217a6a22e234be86", "block.gas_used": 105393, "block.tx_count": 1, "timing.execution_ms": "0.063", "timing.state_read_ms": "0.006", "timing.state_hash_ms": "0.465", "timing.commit_ms": "73.504", "timing.total_ms": "74.039", "throughput.mgas_per_sec": "1671.79", "state_reads.accounts": 7, "state_reads.storage_slots": 0, "state_reads.code": 0, "state_reads.code_bytes": 0, "state_writes.accounts": 3, "state_writes.accounts_deleted": 0, "state_writes.storage_slots": 0, "state_writes.storage_slots_deleted": 0, "state_writes.code": 1, "state_writes.code_bytes": 240, "state_writes.eip7702_delegations_set": 0, "state_writes.eip7702_delegations_cleared": 0, "cache.account.hits": 32, "cache.account.misses": 52, "cache.account.hit_rate": "38.10", "cache.storage.hits": 0, "cache.storage.misses": 0, "cache.storage.hit_rate": "0.00", "cache.code.hits": 0, "cache.code.misses": 0, "cache.code.hit_rate": "0.00" }, "target": "reth::slow_block" }